< previous page page_566 next page >

Page 566
The first parameter, as usual, is the window handle to the combo box. The second parameter is a constant value that tells the combo box which method it needs to invoke. In this case, its the constant CB_LIMITTEXT. The third parameter specifies the number of characters to use as the limit for the text portion of the combo box. The fourth parameter is unused; therefore, a long zero (0) is passed. The & after the parameter informs Visual Basic to make this a long value when its passed to the SendMessage() function.
Changing the List Portion of a Combo Box
A combo box is made up of a text box and a list box. The list portion drops down when the user clicks the down-arrow button on the right side of the combo box. Sometimes you might want to have the combo box list already dropped down when you open a form or when the user tabs to that control. This can also be accomplished with the SendMessage() function:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdDrop_Click()
   Dim lngRet As Long

   ' Drop down the list portion
   ' of the combo box
   lngRet = SendMessage(cboStates.hwnd, _
                       CB_SHOWDROPDOWN, _
                       1, _
                       0&)

End Sub
The third parameter should be set to a nonzero value to make the combo box drop down its list. Similarly, you can close the list portion programmatically by passing a zero value as the third parameter:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdCloseUp_Click()
   Dim lngRet As Long

   ' Close up the list portion
   ' of the combo box
   lngRet = SendMessage(cboStates.hwnd, _
                       CB_SHOWDROPDOWN, _
                       0, _
                       0&)
End Sub

 
< previous page page_566 next page >

If you like this book, buy it!